package rursu.dal.managers;

import rursu.dal.managers.interfaces.IMovieDAL;
import rursu.dal.managers.interfaces.IMovieDetailsDAL;
import rursu.dal.managers.interfaces.IMovieImageDAL;
import rursu.dal.managers.interfaces.IMovieSearchDAL;
import rursu.dal.managers.interfaces.IMoviesListDAL;
import rursu.dal.managers.interfaces.IMoviesListPairDAL;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class DataBaseManager {
	
	public static final String DATABASE_NAME = "movie_browser";
	public static final int DATABASE_VERSION = 1;
	
	private static String LOGGER_TAG = DataBaseManager.class.getCanonicalName();
	
	private static DataBaseHelper dataBaseHelper;
	
	private IMovieDAL movieDALManager;
	private IMoviesListDAL moviesListDALManager;
	private IMoviesListPairDAL moviesListPairDALManager;
	private IMovieDetailsDAL movieDetailsDALManager;
	private IMovieImageDAL movieImageDALManager;
	private IMovieSearchDAL movieSearchDALManager;

	public DataBaseManager (Context context) {
		
		Log.d(LOGGER_TAG, "constructor launched");
		dataBaseHelper = new DataBaseHelper( context, DATABASE_NAME, DATABASE_VERSION );
		
		SQLiteDatabase db = dataBaseHelper.getWritableDatabase();
		
		movieDALManager = new MovieDALManager(db);
		moviesListDALManager = new MoviesListDALManager(db);
		moviesListPairDALManager = new MoviesListPairDALManager(db);
		movieDetailsDALManager = new MovieDetailsDALManager(db);
		movieImageDALManager = new MovieImageDALManager(db);
		movieSearchDALManager = new MovieSearchDALManager(db);
	}

	public void close() {
		
		Log.v("LA LA LA LA LA LA LA LA", "------------------ close()!!!!!!! +++++++++++++++++++");
		
		dataBaseHelper.close();
	}
	
	public IMovieDAL getMovieDALManager() {
		return movieDALManager;
	}

	public void setMovieDALManager(IMovieDAL movieDALManager) {
		this.movieDALManager = movieDALManager;
	}

	public IMoviesListDAL getMoviesListDALManager() {
		return moviesListDALManager;
	}

	public void setMoviesListDALManager(IMoviesListDAL moviesListDALManager) {
		this.moviesListDALManager = moviesListDALManager;
	}

	public IMoviesListPairDAL getMoviesListPairDALManager() {
		return moviesListPairDALManager;
	}

	public void setMoviesListPairDALManager(
			IMoviesListPairDAL moviesListPairDALManager) {
		this.moviesListPairDALManager = moviesListPairDALManager;
	}

	public IMovieDetailsDAL getMovieDetailsDALManager() {
		return movieDetailsDALManager;
	}

	public void setMovieDetailsDALManager(
			IMovieDetailsDAL movieDetailsDALManager) {
		this.movieDetailsDALManager = movieDetailsDALManager;
	}

	public IMovieImageDAL getMovieImageDALManager() {
		return movieImageDALManager;
	}

	public void setMovieImageDALManager(IMovieImageDAL movieImageDALManager) {
		this.movieImageDALManager = movieImageDALManager;
	}

	public IMovieSearchDAL getMovieSearchDALManager() {
		return movieSearchDALManager;
	}

	public void setMovieSearchDALManager(IMovieSearchDAL movieSearchDALManager) {
		this.movieSearchDALManager = movieSearchDALManager;
	}
	
}
